package com.leo.ibatis.demo.service.impl;

import java.util.List;

import com.leo.ibatis.demo.base.Service;
import com.leo.ibatis.demo.criteria.SignonCriteria;
import com.leo.ibatis.demo.dao.SignonDao;
import com.leo.ibatis.demo.domain.Signon;
import com.leo.ibatis.demo.service.SignonService;

public class SignonServiceImpl extends Service implements SignonService {

	private SignonDao signonDao;

	public void setSignonDao(SignonDao signonDao) {
		this.signonDao = signonDao;
	}

	public void insert(Signon signon) {
		signonDao.insert(signon);
	}

	public int update(Signon signon) {
		int actualRowsAffected = 0;
		
		String username = signon.getUsername();

		Signon _oldSignon = signonDao.select(username);
		
		if (_oldSignon != null) {
			actualRowsAffected = signonDao.update(signon);
		}
		
		return actualRowsAffected;
	}

	public int delete(String username) {
		int actualRowsAffected = 0;
		
		Signon _oldSignon = signonDao.select(username);
		
		if (_oldSignon != null) {
			actualRowsAffected = signonDao.delete(username);
		}
		
		return actualRowsAffected;
	}
	
	public Signon select(String username) {
		return signonDao.select(username);
	}

	public List<Signon> list(SignonCriteria signonCriteria) {
		return signonDao.list(signonCriteria);
	}
	
	public List<Signon> listOnPage(SignonCriteria signonCriteria) {
		return signonDao.listOnPage(signonCriteria);
	}

}
